#!/usr/bin/env python3
# -*- coding:utf-8 -*-

from MOMA.MOMA_V1.lib.core.cores import Core


class Command:
    def __init__(self):
        self.enterprise = None

    def run_core(self):
        self.get_cmd()
        url_obj = Core(self.enterprise)
        url = url_obj.get_url()
        # 获取ip
        url_obj.ip.format(url)
        ip = url_obj.get_ip()

        # 扫描端口
        # url = 'suning.ifdachina.com'
        # ip = '156.242.133.54'
        port_list = url_obj.get_port(ip)

        # 获取email
        first_url = url.split('.')
        del (first_url[0])
        first_url = '.'.join(first_url)
        print(first_url)
        url_obj.get_email(first_url)

        # 获取banner
        banner_detail = url_obj.get_banner(ip, port_list)
        print(banner_detail)

    def get_cmd(self) -> str:
        self.enterprise = input("请输入企业名称\n")
        self.enterprise = self.enterprise.split("//")[-1]

    # TODO 接收输入的查询url以及条件
    # def choose_to_run(self) -> str:
    #     self.enterprise = input("请输入条件")
    #     pass